The R codes of SDCR (Systematically Dependent Competing Risks)
Version 1.0-0, July, 2009
Copyright (C) 2009 Kentaro Fukumoto (Kentaro.Fukumoto@gakushuin.ac.jp)
http://www-cc.gakushuin.ac.jp/~e982440/research/SDCR/

1. Introduction

The codes in this zipped directory "main.0.1-1.zip" is used to replicate the analyses in the following article in the open source statistical software package R. If you (modify and) use these codes, please cite this article.

Fukumoto, Kentaro. forthcoming.
"Systematically Dependent Competing Risks and Strategic Retirement."
American Journal of Political Science. 53(3): #

Below, "x.y-z" represents an appropriate version number.

2. How to Replicate the Tables and Figures in the Article

I assume you have unzipped "main.x.y-z.zip" to get the directory "main". 

2.1. "Monte Carlo Simulation" Section
Start R and set this "main" directory as the working directory. If, for example, the "main" directory is on the root directory C, you should type in R 
> setwd("C:/main")
Or you may start R by double-clicking the file "d.x.y-z.Rdata" in the "main" directory.
2.1.1 Easy Way. Implementation of Monte Carlo simulation takes my computer 1 week. If you want to skip calculation and just see the results (as I recommend), download the file "MC.x.y-z.zip" from my SDCR website mentioned above. Unzip it to get the file "MC.x.y-z.Rdata". Put it in the "main" directory. Then, run the file "run.me.MC.x.y-z.r". Figures 1 through 3 are built.
2.1.2. Long Way. If you want to execute Monte Carlo simulation by yourself, comment out
# load("MC.x.y-z.Rdata")
in "run.me.MC.x.y-z.r" and, instead, run in R
> source("MC.ext.x.y-z.r")
> source("MC.x.y-z.r")

2.2. "Reanalysis" Section
Shut down R (because simulation file is so large that computation is slow), restart R and set the "main" directory as the working directory. Before reanalysis, you should download the original data file of the following book:

Box-Steffensmeier, Janet M., and Bradford S. Jones. 2004. 
Event History Modeling: A Guide for Social Scientists.
Cambridge, UK: Cambridge University Press.

As of Februrary 2009, the data is at the book's website
http://psfaculty.ucdavis.edu/bsjjones/eventhistory.html
Or you may get the file directly by typing on browser
http://psfaculty.ucdavis.edu/bsjjones/career.dta
These pages are linked from my SDCR website.

Put the data file "career.dta" in the "main" directory. Run the file "run.me.reanalysis.x.y-z.r". Tables 1 and 2 as well as Figure 4 are built.

3. Supplement Analyses

3.1. "Discussion" Section
Monte Carlo simulation of omitted variable bias is mentioned but not reported in the paper (p. 27). Shut down R, restart R and set the "main" directory as the working directory. 
3.1.1 Easy Way. Implementation of Monte Carlo simulation takes my computer 1 week. If you want to skip calculation and just see the results (as I recommend), download the file "MC.omit.x.y-z.zip" from my SDCR website. Unzip it to get the file "MC.omit.x.y-z.Rdata". Put it in the "main" directory. Then, run the file "run.me.MC.omit.x.y-z.r". Several figures are built.
3.1.2. Long Way. If you want to execute Monte Carlo simulation by yourself, comment out
# load("MC.omit.x.y-z.Rdata")
in "run.me.MC.omit.x.y-z.r" and, instead, run in R
> source("MC.ext.omit.x.y-z.r")
> source("MC.omit.x.y-z.r")

4. Explanation of Files

4.1. SDCR files 
rho4.x.y-z.r = Full model. (pp. 5-14, 30)
rho1.x.y-z.r = Simple model. (p. 25)
rho0.x.y-z.r = Unrestricted model. (p. 25)
rhoall.x.y-z.r = common auxiliary file for all SDCR models

4.2. Main Monte Carlo Simulation
run.me.MC.x.y-z.r = An interface file. If you run this, you get Figures 1 through 3.
MC.x.y-z.r = A background file. Setup parameters and repeat the routine file MC.ext.x.y-z.r.
MC.ext.x.y-z.r = An EXTension file of MC.x.y-z.r. This runs a single simulation: sampling data and estimating parameters.
MC.x.y-z.Rdata = The R output file of simulation. This is not in the compressed main directory. You shoud download it from my SDCR website
makeMCfigure.x.y-z.r = making Figures 1 through 3.

4.3. Supplement Monte Carlo Simulation of Omitted Variable Bias
All files contain ".omit" in their names and corresond the files of Reported Monte Carlo Simulation
run.me.MC.omit.x.y-z.r = An interface file. If you run this, you get figures.
MC.omit.x.y-z.r = A background file. Setup parameters and repeat the routine file MC.ext.x.y-z.r.
MC.ext.omit.x.y-z.r = An EXTension file of MC.x.y-z.r. This runs a single simulation: sampling data and estimating parameters.
MC.omit.x.y-z.Rdata = The R output file of simulation. This is not in the compressed main directory. You shoud download it from my SDCR website
makeMCfigure.omit.x.y-z.r = making figures.

4.4. Reanalysis
run.me.reanalysis.x.y-z.r = An interface file. If you run this, you get Tables 1 and 2 as well as Figure 4.
replication.of.original.x.y-z.r = Replicate the original result (Box-Steffensmeier and Jones, 2004, Table 10.6). The upper panel of Table 1 is made. 
career.dta = The original data of Box-Steffensmeier and Jones (2004, Table 10.6). This is not in the compressed main directory. You shoud download it from http://psfaculty.ucdavis.edu/bsjjones/career.dta
d.x.y-z.Rdata = The variable ".d" of an older version of the original file, careerAM.dta, downloaded from http://www.u.arizona.edu/~bsjones/eventhistory.html on June 29, 2005.
table1.lower.panel.x.y-z.r = Making the lower panel of Table 1 by way of the SDCR model.
derivative.x.y-z.r = Making Figure 4.
results.x.y-z.Rdata = The R output file you get when you run "run.me.reanalysis.x.y-z.r"

4.5. General Use
multinom.robust.sde.x.y-z.r = Calculate robust standard errors from an output of the "multinom" command in the "nnet" library.

5. Revision History

Version 1.0-0, July, 2009
read.me.1.0-0.txt
The paper is published.
The pages are confirmed.
The website directory is changed.

Ver. 0.1-2, Apr. 14, 2009
read.me.0.1-2.txt
Paper title is corrected.
run.me.MC.0.1-2.r
Annotation revised for checking if the real data and the Monte Carlo simulation are comparable (footnote 13)
run.me.reanalysis.0.1-2.r
add the code for checking if the real data and the Monte Carlo simulation are comparable (footnote 13)

Ver. 0.1-1, Apr. 8, 2009
read.me.0.1-1.txt
Paper title is corrected.

Ver. 0.1-0, Feb. 11, 2009
The initial codes are uploaded upon acceptance of the manuscript by AJPS. I plan to polish annotation in near future.
